cmake_minimum_required (VERSION 2.6)
project (SkcirBoard)

set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "-pipe -std=c++11 -Wall -Wextra -pedantic -O2 -Os -fno-rtti")
set(CMAKE_CXX_LINK_FLAGS "")

if(DEBUG_TARGET)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -g3")
    message(STATUS "${PROJECT_NAME} target: DEBUG")
else()
    if(RELEASE_TARGET)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer -DNDEBUG -mtune=native -march=native")
        message(STATUS "${PROJECT_NAME} target: RELEASE")
    else()
        message(STATUS "${PROJECT_NAME} target: DEFAULT")
    endif()

    if(CMAKE_COMPILER_IS_GNUCXX)
            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections")
            set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -s -Wl,--gc-sections")
    endif()
endif()

# jsonpp library creation
include_directories(SYSTEM ${CMAKE_CURRENT_LIST_DIR}/external/jsonpp/include)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/external/jsonpp)

# gtest/gmock library creation
include_directories(SYSTEM ${CMAKE_CURRENT_LIST_DIR}/external/gmock/include ${CMAKE_CURRENT_LIST_DIR}/external/gmock/gtest/include)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/external/gmock)

# websocket app (no lib target - only to see headers in project view)
include_directories(${CMAKE_CURRENT_LIST_DIR}/external ${CMAKE_CURRENT_LIST_DIR}/external/websocketpp)
file(GLOB_RECURSE WEBSOCKETS_IMPLEMENTATION ${CMAKE_CURRENT_LIST_DIR}/external/websocketpp/*.hpp)
add_custom_target(WEBSOCKETS SOURCES ${WEBSOCKETS_IMPLEMENTATION})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")

add_subdirectory(src)
add_subdirectory(tst)
